package com.fqgj.xjd.user.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.xjd.user.dao.UserQuotaDao;
import com.fqgj.xjd.user.entity.UserQuotaEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* User: zhangxingyun
* Date: 2017-07-20
* Time: 18:38:53.168
*/

@Repository
public class UserQuotaDaoImpl extends AbstractBaseMapper<UserQuotaEntity> implements UserQuotaDao {

    public UserQuotaEntity getQutoaByuserCodeAndCategory(Map<String, Object> map) {
        return getSqlSession().selectOne(getStatement("getQutoaByuserCodeAndCategory"), map);
    }

    public void updateByUserCodyAndCategory(UserQuotaEntity userQuotaEntity) {
        getSqlSession().update(getStatement("updateByUserCodyAndCategory"), userQuotaEntity);
    }

    public void saveQuota(UserQuotaEntity userQuotaEntity){
        getSqlSession().insert(getStatement("saveQuota"),userQuotaEntity);
    }

    @Override
    public List<UserQuotaEntity> getAllQutoaByuserCode(String userCode) {

        return getSqlSession().selectOne(getStatement("getAllQutoaByuserCode"), userCode);
    }

    @Override
    public List<UserQuotaEntity> getAllQuotaByUserCodes(List<String> userCodes) {
        Map<String, Object> map = new HashMap<>();
        map.put("userCodes", userCodes);
        return getSqlSession().selectList(getStatement("getAllQuotaByUserCodes"), map);
    }
}